import Vue from 'vue';
import Router from 'vue-router';

const originalReplace = Router.prototype.replace;
Router.prototype.replace = function replace(location) {
	return originalReplace.call(this, location).catch(err => err);
};
const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
	return originalPush.call(this, location).catch(err => err)
};

Vue.use(Router);

export default new Router({
	routes: [{
			path: '/',
			redirect: '/index'
		},
		{
			path: '/index',
			component: () => import('../components/page/index.vue'),
			meta: {
				title: '校园循环利用宝'
			}
		},
		{
			path: '/search',
			component: () => import('../components/page/search.vue'),
			meta: {
				title: '闲置二手物品 | 校园循环利用宝'
			}
		},
		{
			path: '/me',
			component: () => import('../components/page/me.vue'),
			meta: {
				title: '个人中心 | 校园循环利用宝'
			}
		},
		{
			path: '/message',
			component: () => import('../components/page/message.vue'),
			meta: {
				title: '消息 | 校园循环利用宝'
			}
		},
		{
			path: '/release',
			component: () => import('../components/page/release.vue'),
			meta: {
				title: '发布二手物品 | 校园循环利用宝'
			}
		},
		{
			path: '/details',
			component: () => import('../components/page/idle-details.vue'),
			meta: {
				title: '二手物品详情 | 校园循环利用宝'
			}
		},
		{
			path: '/order',
			component: () => import('../components/page/order.vue'),
			meta: {
				title: '订单详情 | 校园循环利用宝'
			}
		},
		{
			path: '/login',
			component: () => import('../components/page/login.vue'),
			meta: {
				title: '登录 | 校园循环利用宝'
			}
		},
		{
			path: '/sign-in',
			component: () => import('../components/page/sign-in.vue'),
			meta: {
				title: '注册 | 校园循环利用宝'
			}
		},
		{
			path: '/login-admin',
			component: () => import('../components/page/login-admin.vue'),
			meta: {
				title: '后台登陆'
			}
		},
		{
			path: '/platform-admin',
			component: () => import('../components/page/platform-admin.vue'),
			meta: {
				title: '后台管理'
			}
		},
		{
			path: '/assist',
			component: () => import('../components/common/assist.vue'),
			meta: {
				title: '帮助中心'
			}
		},
		// Shopping
		{
			path: '/Shopping',
			component: () => import('../components/common/Shopping.vue'),
			meta: {
				title: '购物流程'
			}
		},
		{
			path: '/chat',
			component: () => import('../components/common/chat.vue'),
			meta: {
				title: '聊天中心'
			}
		},
		{
			path: '/AppAboutUs.vue',
			component: () => import('../components/common/AppAboutUs.vue'),
			redirect: '/EnteroriseService.vue',
			children: [{
					path: '/EnteroriseService.vue',
					component: () => import('../components/common/EnteroriseService.vue'),
					meta: {
						title: '企业服务'
					}
				},
				{
					path: '/Cooperate.vue',
					component: () => import('../components/common/Cooperate.vue'),
					meta: {
						title: '商务合作'
					}
				},
				{
					path: '/ContactUs.vue',
					component: () => import('../components/common/ContactUs.vue'),
					meta: {
						title: '联系我们'
					}
				},
				{
					path: '/CommonProblem.vue',
					component: () => import('../components/common/CommonProblem.vue'),
					meta: {
						title: '常见问题'
					}
				}
			],
			meta: {
				title: '关于我们'
			}
		},
		{
			path: '/help',
			component: () => import('../components/common/help.vue'),
			meta: {
				title: '新手指南'
			}
		},
		{
			path: '/book',
			component: () => import('../components/common/book.vue'),
			meta: {
				title: '图书专栏'
			}
		},
		{
			path: '*',
			redirect: '/'
		}
	]
});